//
//  MCquyuVC.m
//  MCmeituan
//
//  Created by Mc on 15/12/14.
//  Copyright © 2015年 Mc. All rights reserved.
//

#import "MCquyuVC.h"
#import "MJExtension.h"
#import "MCquyuData.h"
#import "MCLRTablView.h"


@interface MCquyuVC () <MCLRTablViewDatasource, MCLRTablViewDelegate>

@property (nonatomic, strong) NSArray *quyuData;

@end

@implementation MCquyuVC

-(NSArray *)quyuData
{
    if (_quyuData == nil) {
        _quyuData = [MCquyuData objectArrayWithFilename:@"gz.plist" ];
    }
    return _quyuData;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setUpLRTableView];
}

- (void)setUpLRTableView
{
    MCLRTablView *lrv = [MCLRTablView lrTableview];
    [self.view addSubview:lrv];
    lrv.autoresizingMask = UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight ;
    lrv.frame = self.view.bounds;
    
    lrv.datasource = self;
    lrv.fenleiData = self.quyuData;
    lrv.delegate = self;
    
}
#pragma mark --代理方法required
- (NSInteger)numberOfRowsInSection:(MCLRTablView *)lrTableView
{
    return self.quyuData.count;
}

- (NSString *)lrTableView:(MCLRTablView *)lrTableView titleInLeftRow:(NSInteger)lRow
{
    MCquyuData *quyu = self.quyuData[lRow];
    
    return quyu.name;
}

- (NSArray *)lrTableView:(MCLRTablView *)lrTableView subDataInlLeftRow:(NSInteger)lRow
{
    MCquyuData *quyu = self.quyuData[lRow];
    
    return quyu.subregions;
}

- (void)lrTableView:(MCLRTablView *)lrTableView leftDidSelect:(NSInteger)leftRow andRightRow:(NSInteger)rightRow
{
    MCquyuData *quyu = self.quyuData[leftRow];
    NSString *quyuStr = quyu.subregions[rightRow];
    
    NSDictionary *dict = @{
                           @"quyu" : quyu,
                           @"quyustr" : quyuStr
                           };
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"MCquyuNSNotification" object:self userInfo:dict];


}
@end
